// pages/electronic-billing/electronic-billing.js
var api = require('../../utils/api.js')
var util = require('../../utils/util.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    expenditure: '', //总支出
    income: '', //总收入
    billList: [
      {},
      {
        type: '充值',
        icon: '../../images/shouru.png',
      },
      {
        type: '消费',
        icon: '../../images/zhichu.png',
      },
      {
        type: '退款',
        icon: '../../images/shouru.png',
      },
      {
        type: '返利',
        icon: '../../images/shouru.png',
      },
      {
        type: '追加',
        icon: '../../images/shouru.png',
      },
      {
        type: '扣除',
        icon: '../../images/zhichu.png',
      },
    ],
    date: '',
    date1: '',
    getIPage: '',
  },
  bindDateChange: function (e) {
    let that = this
    that.setData({
      date: e.detail.value
    })
    that.getIPage()
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  // 搜索栏
  showInput: function (e) {
    this.setData({
      inputShowed: true
    });
    console.log(e)
  },
  hideInput: function () {
    this.setData({
      inputVal: "",
      inputShowed: false
    });
  },
  clearInput: function () {
    this.setData({
      inputVal: ""
    });
  },
  inputTyping: function (e) {
    this.setData({
      inputVal: e.detail.value
    });

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this
    that.setData({
      date: util.formatTime(new Date()),
      date1: util.formatTime(new Date()),
    })
    that.getIPage()
  },
  getIPage: function () {
    let that = this
    api.getIPageRecord({
      page: {
        size: 1000
      },
      createtimeCheck: that.data.date,

    }).then(res => {
      if (res.result) {
        console.log(res)
        that.setData({
          expenditure: res.body.expenditure, //总支出
          income: res.body.income, //总收入
          getIPage: res.object.records
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
})